﻿$(document).ready(function() {

    // Datepicker
    $(".datepicker").datepicker({
    // minDate: '<%=DateTime.Now.ToShortDate() %>',
        onSelect: function() { }
    });

    $('.a-delete').click(function() {
        if (confirm('Do you sure delete this reservation?')) {

            var _GuestID = $(this).attr("reservationid");
            var _Index = $(this).attr("index");

            DeleteItem(_GuestID, _Index);
        }
        return false;
    });

    function DeleteItem(Id, Index) {
        var jsonStr = "{reservationID:'" + Id + "'}";
        $.ajax({
            type: "POST",
            url: "/Update.asmx/DeleteReservation",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            data: jsonStr,
            success: function(msg) {
                $('.span-alert-' + Index).text("deleted").css("font-size", "8pt").css("color", "red");
                return false;
            },
            error: function() {
                alert("Occurs errors");
                return false;
            }
        });
    }
});

